package com.atguigu.gmall.service.config;

import com.atguigu.gmall.common.result.Result;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 配置类:MybatisPlus有关的都配置在这
 */
@EnableTransactionManagement
@Configuration
public class ApplicationPlusConfiguration {

    /**MybatisPlus的功能拦截器
     *
     * @return
     */
    @Bean
    public MybatisPlusInterceptor interceptor(){
        //总拦截器
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        //小拦截器放到总拦截器中
        //准备分页拦截器
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        paginationInnerInterceptor.setOverflow(true);//允许页码溢出
        mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
        return mybatisPlusInterceptor;

    }


}
